<?php
/**
 * 描述：访谈-列表。
 * @final
 */
final class Exec_News_Interview_Enterprise_List extends Exec_News_Public
{
    public function __construct()
    {
        parent::Get();

        #获取参数
        $type=Functions::UrlArgs('type');

        #定义标量
        $contentTitle=NULL;
        $params=array();

        #获取数据
        switch($type)
        {
            case 'ranking':
                $data=$this->Get_Ranking();
            break;
            default:
                $data=$this->Get_Common();
            break;
        }

        #配置参数
        $params['type']=$type;

        #渲染输出
        View::Assign('EnterpriseList',@$data['Record']);
        View::Assign('InterviewList_PageMenu',PagerFactory::Create('Common')->Fetch($data,array
        (
            'URL'=>'/exec.php?action=news_interview_enterprise_list',
            'Parameters'=>$params,
            'IsDetail'=>TRUE
        )));        
        View::Display('news/interview/enterprise/list.tpl');
    }

    /**
     * 描述：获取数据。
     * @access private
     */
    private function Get_Common()
    {
        #获取数据
        $data=DB::GetData('select * from enterprise order by M_IsTop desc,M_IsTop_Datetime desc,ID desc limit ?,20');
        foreach($data['Record'] as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$row['ThumbnailPath'];
        }
        return $data;
    }

    /**
     * 描述：按浏览次数序获取数据。
     * @access private
     */
    private function Get_Ranking()
    {
        #获取数据
        $data=DB::GetData('select * from enterprise order by VisitsCount desc,ID desc limit ?,20');
        foreach($data['Record'] as &$row)
        {
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$row['ThumbnailPath'];
        }
        return $data;
    }
}
?>